package org.corey.share.auth;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class PermissionLoader implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent event) {
		PermissionUtil.removeAdminPermission();
	}

	public void contextInitialized(ServletContextEvent event) {
		ServletContext sc = event.getServletContext();
		PermissionUtil.setServletContext(sc);
		String permissionConfigPath = sc
				.getInitParameter("permissionConfigPath");
		RoleAccessStrategory ras = new DefaultAuthFileParsor()
				.parse(permissionConfigPath);
		PermissionUtil.setAdminPermission(ras);
	}
	
}
